package com.sy.simpleegg.platform.kkb.network.interceptor

import base.INetworkRequiredInfo
import okhttp3.Interceptor
import okhttp3.Request
import okhttp3.Response
import java.io.IOException

/**
 * @author sy
 * @date 2024/10/11 15:14
 * @desc
 */
class CommonRequestInterceptor: Interceptor {
    private var requiredInfo: INetworkRequiredInfo? = null

    fun CommonRequestInterceptor(requiredInfo: INetworkRequiredInfo?) {
        this.requiredInfo = requiredInfo
    }

    @Throws(IOException::class)
    override fun intercept(chain: Interceptor.Chain): Response {
        val builder: Request.Builder = chain.request().newBuilder()
        builder.addHeader("os", "android")
        builder.addHeader("appVersionCode", requiredInfo!!.appVersionCode.toString() + "")
        builder.addHeader("appVersionName", requiredInfo!!.appVersionName)
        return chain.proceed(builder.build())
    }
}